
// Code for LoginScreen.mxml

import flash.events.Event;

import navigator.State;

import summit.data.AccountToken;
import summit.events.BasecampAPIEvent;

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

private static const TITLE:String = "Basecamp Navigator";
private static const LOGINMSG:String = 
"To navigate a Basecamp account, please provide some account information."

/** Called by Navigator after the application complete event. */
public function wireEvents():void
{
	// need to sign up for the status event for the artifact tree to get 
	// notification of successful API call.
	State.projectWrapper.loader.addEventListener(BasecampAPIEvent.OK,
	handleProjectOKEvent);
}

/** @private Called when user clicks 'Sign In' from the UI. **/
private function handleLoginClick(e:MouseEvent):void
{
	State.accountToken = new AccountToken(userInput.text, passwordInput.text,
	urlInput.text);
	
	dispatchEvent(new Event(Event.CONNECT));
}

/** @private Called Summit successfully downloads projects. **/
private function handleProjectOKEvent(e:BasecampAPIEvent):void
{		
	// We're in a good login state
	this.visible = false;	
		
	// Don't need to hear anymore ... :)
	State.projectWrapper.loader.removeEventListener(BasecampAPIEvent.OK, 
	handleProjectOKEvent);
}
//////////////////////////////////////////////////////// gmarius@tyemill.com //